package com.jianguozh.difs.framework.security;

import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.util.Collection;

/**
 * 认证用户
 *
 * @author hanrs
 * @email 4076130@qq.com
 * @since 2022/3/11 9:07
 */
public class AuthenticatedUser implements UserDetails {

    private String id;
    private String issueClientId;
    private String username;
    private String password;
    private String org;
    private String orgId;
    private Boolean orgDefault;
    private String name;
    private String avatar;
    private Boolean status;
    private Collection<? extends GrantedAuthority> authorities;
    private Boolean pwdInited;
    private Boolean locked;

    public AuthenticatedUser() {
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getIssueClientId() {
        return issueClientId;
    }

    public void setIssueClientId(String issueClientId) {
        this.issueClientId = issueClientId;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getOrg() {
        return org;
    }

    public void setOrg(String org) {
        this.org = org;
    }

    public String getOrgId() {
        return orgId;
    }

    public void setOrgId(String orgId) {
        this.orgId = orgId;
    }

    public Boolean getOrgDefault() {
        return orgDefault;
    }

    public void setOrgDefault(Boolean orgDefault) {
        this.orgDefault = orgDefault;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getAvatar() {
        return avatar;
    }

    public void setAvatar(String avatar) {
        this.avatar = avatar;
    }

    public Boolean getStatus() {
        return status;
    }

    public void setStatus(Boolean status) {
        this.status = status;
    }

    public void setAuthorities(Collection<? extends GrantedAuthority> authorities) {
        this.authorities = authorities;
    }

    public Boolean getPwdInited() {
        return pwdInited;
    }

    public void setPwdInited(Boolean pwdInited) {
        this.pwdInited = pwdInited;
    }

    public Boolean getLocked() {
        return this.locked;
    }

    public void setLocked(Boolean locked) {
        this.locked = locked;
    }

    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return this.authorities;
    }

    @Override
    public String getPassword() {
        return this.password;
    }

    @Override
    public String getUsername() {
        return this.username;
    }

    @Override
    public boolean isAccountNonExpired() {
        return true;
    }

    @Override
    public boolean isAccountNonLocked() {
        return null == locked ? Boolean.TRUE : !locked;
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return true;
    }

    @Override
    public boolean isEnabled() {
        return true;
    }


}
